﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using RestSharp;
using WebApiDemo.Contract;
using Ymatou.ServiceCenter;

namespace WebApplicationDemo1
{
    [ServiceRegister("api.aspx", Method.GET)]
    public partial class api : System.Web.UI.Page
    {
        protected void Page_Load(object sender, EventArgs e)
        {
            string clientIp = Request.GetClientIp();
            string serverIpLink = Request.GetServerIpLink();

            StringBuilder sb = new StringBuilder();
            WebApplicationDemo2.Contract.EmptyRequest request1 = new WebApplicationDemo2.Contract.EmptyRequest();
            WebApplicationDemo2.Contract.EmptyResponse response1 = ServiceClient.Execute<WebApplicationDemo2.Contract.EmptyRequest, WebApplicationDemo2.Contract.EmptyResponse>(request1);
            sb.AppendLine(response1.Result);

            WebApplicationDemo4.Contract.EmptyRequest request2 = new WebApplicationDemo4.Contract.EmptyRequest();
            WebApplicationDemo4.Contract.EmptyResponse response2 = ServiceClient.Execute<WebApplicationDemo4.Contract.EmptyRequest, WebApplicationDemo4.Contract.EmptyResponse>(request2);
            sb.AppendLine(response2.Result);
            //WebApiDemo.Contract.OwinTestRequest request3 = new OwinTestRequest();
            //OwinTestResponse response3 = ServiceClient.Execute<OwinTestRequest, OwinTestResponse>(request3);
            //sb.AppendLine(response3.Result);


            //ServiceClient.ExecuteAsync<WebApplicationDemo2.Contract.EmptyRequest, WebApplicationDemo2.Contract.EmptyResponse>(request, (response) =>
            //{
            //    string reslut = response.Result;
            //}, (exception) =>
            //{
            //    string message = exception.Message;
            //});
            //string reslut = ServiceClient.Execute(request);

            Response.Write("demo1+" +string.Format("clientIp:{0};serverIpLink:{1}",clientIp,serverIpLink)+ sb);
            Response.End();
        }
    }
}